package castle.defense.project;

import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

/**
 * "Start" of the "game" activity. Basically a wrapper to open the game view and start the game thread.
 * 
 * @author Daniel Wasserman
 *
 */
public class GameActivity extends Activity {
	private GameView mv;
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		
		GraphicsEngine.addImage(Enemy.enemy1, this.getResources().getDrawable(R.drawable.ranged_enemy1),4,4,1);
		GraphicsEngine.addImage(Enemy.enemy2, this.getResources().getDrawable(R.drawable.melee_enemy1),5,5,1);
		GraphicsEngine.addImage(Enemy.juggernaut, this.getResources().getDrawable(R.drawable.juggernaut),12,12,1);
		GraphicsEngine.addImage(Castle.castle, this.getResources().getDrawable(R.drawable.wall), 100, 15,2);
		
		Score.initialize();
	}

	@Override
	public void onResume() {
		SoundManager.setBackground(R.raw.medieval_game);
		mv = new GameView(this);
		this.setContentView(mv);
		super.onResume();
	}
	
	@Override
	public void onPause() {
		SoundManager.stopBackground();
		mv.stop();
		super.onPause();
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent e) {
		mv.onKeyDown(keyCode, e);
		return super.onKeyDown(keyCode, e);
	}
}